<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{path:'/3-1'}">用户管理</el-breadcrumb-item>
      <el-breadcrumb-item :to="{path:'/3-1'}">用户列表</el-breadcrumb-item>
      <el-breadcrumb-item :to="{path:'/3-1'}">用户查看</el-breadcrumb-item>
    </el-breadcrumb>
    <el-row style="margin-top: 50px">
      <el-col :span="20" :offset="2">
        <el-form :model="tableData" ref="tableData" class="demo-ruleForm" :inline="true">
          <div>
            <el-form-item label="宝宝头像">
              <img :src="tableData.img">
            </el-form-item>
          </div>
          <div>
            <el-form-item label="宝宝昵称" prop="name">
              <el-input v-model="tableData.name" :disabled="true">
              </el-input>
            </el-form-item>
            <el-form-item label="宝宝生日" prop="birth">
              <el-input v-model="tableData.birthtime" :disabled="true">
              </el-input>
            </el-form-item>
          </div>
          <el-form-item label="手机号码" prop="phone">
            <el-input v-model="tableData.phone" :disabled="true">

            </el-input>
          </el-form-item>
          <el-form-item label="宝宝性别" prop="sex">
            <el-input v-model="tableData.gender" :disabled="true"></el-input>
          </el-form-item>
          <div>
            <el-form-item>
              <el-button type="primary" @click="wentback">返回</el-button>
            </el-form-item>
          </div>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import axios from 'axios'
  import {
    signinfo
  } from '@/api/signlist/signlist'

  export default {
    name: "UserInfo",
    data() {
      return {
        tableData: {}
      }
    },
    methods: {
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      wentback() {
        this.$router.push({name: 'UserList'})
      },
      submit() {
        console.log(this.ruleForm);
      },
      getDetailInfo() {
        let id = this.$route.query.index;
        signinfo(id).then(this.handleGetDataSucc)
      },
      handleGetDataSucc(res) {
        console.log(res);
        this.tableData = res.data;
        this.tableData.birthtime=this.$moment(this.tableData.birth).format("YYYY-MM-DD HH:mm:ss")
        switch (res.data.sex) {
          case 1:
            this.tableData.gender = '男孩';
            break;
          case 2 :
            this.tableData.gender = '女孩';
            break;
          case 3:
            this.tableData.gender = '人妖';
            break;
        }
      },
      wentback() {
        this.$router.push({name: 'UserList'})
      }
    },
    mounted() {
      console.log(this.$route.params.index);
      this.getDetailInfo();
    }
  }
</script>

<style scoped>

</style>
